package sh.wn36.vehiclemanage.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sh.wn36.vehiclemanage.entity.InspectionRecord;
import sh.wn36.vehiclemanage.entity.dto.InspectionQuery;
import sh.wn36.vehiclemanage.entity.qz_entity.InspectionRecordList;
import sh.wn36.vehiclemanage.xzy.UnitQuery;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xk
 * @since 2021-04-26
 */
@Mapper
public interface InspectionRecordListMapper extends BaseMapper<InspectionRecordList> {

    @Select("SELECT\n" +
            "        qu.id,\n" +
            "        qu.car_id,\n" +
            "        qu.ins_no,\n" +
            "        qu.ins_date,\n" +
            "        qu.ins_amount,\n" +
            "        qu.vao_id,\n" +
            "        qu.expire_date,\n" +
            "        qu.operator,\n" +
            "        qu.remarks,\n" +
            "        d.unit_name,\n" +
            "        c.car_no,\n" +
            "        e.name\n" +
            "        FROM inspection_record AS qu\n" +
            "        LEFT JOIN car AS c ON   qu.car_id = c.id\n" +
            "        LEFT JOIN current_unit AS d on   qu.vao_id= d.id\n" +
            "        LEFT JOIN driver AS e on   qu.operator= e.id ${ew.customSqlSegment}")
    IPage<InspectionRecordList> selectPages(Page page, @Param(Constants.WRAPPER) Wrapper<InspectionRecordList> queryWrapper);
}
